<!--
 * @Author: your name
 * @Date: 2020-12-17 17:18:28
 * @LastEditTime: 2020-12-24 16:47:47
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\warranty\extendedManagement\importModal.vue
-->
<template>
    <div>
        <el-dialog
        :title="$t('import')"
        :visible="newVisibleEdit"
        class="el-dialog-lg"
        @close="()=>{$store.commit('setNewVisibleEdit',false)}" width="35%"
        :close-on-click-modal='false'
        >
            <el-form ref="form" :model="form" label-width="150px" >
                <el-row :gutter="24">
                    <el-col :span="20" :offset="1">
                        <el-form-item :label="$t('version.versionService.fileURL')" prop="file" :rules="[{ required: true, message: '不能为空'}]">
                            <!-- <el-input v-model="form.file" placeholder="请输入内容"></el-input> -->
                            <fileInput v-model="form.file"></fileInput>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="()=>{$store.commit('setNewVisibleEdit',false)}">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="save('form')">{{$t('save')}}</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import fileInput from '../../../components/common/baseFileInput'
export default {
    components: {
        fileInput
    },
    props: {

    },
    data() {
        return {
            form:{
                file:''
            }
        };
    },
    computed: {
        newVisibleEdit(){
            return this.$store.state.sysStore.newVisibleEdit
        },
        
    },
    watch: {

    },
    created() {

    },
    mounted() {

    },
    methods: {
        async delayCodeImportDelayCode(){
            let res = await this.API.delayCodeImportDelayCode(this.form)
            if(this.comm.showMsg(res.success)){
                this.$store.commit('setNewVisibleEdit',false)
                this.$emit('uploadData',true)
            }
        },
        save(formName){
            this.$refs[formName].validate((valid) => {
              if (valid) {
                  this.delayCodeImportDelayCode()
              } else {
                console.log('error submit!!');
                return false;
              }
            });
        },
    },
};
</script>

<style  lang="less" scoped>

</style>
